<?php
namespace app\tools\logic;
use think\facade\Db;

class ConfigLogic{
	static function getList(){
		$type = input('type', 1);
		$page_size = input('page_size', 10);
		$list = Db::name('config')
					->where('type', $type)
					->order('id asc')
					->paginate($page_size);
		return $list;
	}

	static function save(){
		$config = input('config', []);
		if(!$config){
			return 142;
		}
		foreach($config as $v){
			Db::name('config')
				->where('id', $v['id'])
				->update(['value'=>$v['value']]);
		}
		return 0;
	}
}